outsideworkers <- east_lodes_all2 %>%
filter(w_county %in% eastfips == F)
outsideresidents <- east_lodes_all2 %>%
filter(h_county %in% eastfips == F)
These are the percentile calculations for Virginia counties based on the number of Eastern Shore residents who are employed in that county. These calculations do not include the number of Eastern Shore residents who are employed within the Eastern Shore. For example, the number of people who live in Albemarle County and commute to Charlottesville City are not reflected in this calculations. The bar graphs show the most common and least common work-destination counties for Eastern Shore residents who work outside of the Eastern Shore.
quantile(na.omit(outsideworkers$commutersfromRegion), probs = seq(0, 1, by= 0.05))
## 0% 5% 10% 15% 20% 25% 30% 35% 40% 45% 50% 55% 60% 65% 70% 75%
## 1 1 2 4 4 6 7 9 12 14 16 19 22 26 30 34
## 80% 85% 90% 95% 100%
## 46 73 135 260 568
Bottom 25th percentile (the least common work-destinations for Eastern Shore residents)
# Counties that are in the bottom 25th percentile in terms of number of Eastern Shore residents commuters.
outsideworkers25 <- outsideworkers[which(outsideworkers$commutersfromRegion <= quantile(na.omit(outsideworkers$commutersfromRegion), probs = 0.25)),]
ggplot(outsideworkers25, aes(x = NAME, y = commutersfromRegion))+
geom_bar(stat = 'identity', width = 0.5) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(x = "County", y = "Eastern Shore resident commuters")
Top 75th percentile (the most common work-destinations for Eastern Shore residents who work outside the Eastern Shore)
# Counties that are in the top 75th percentile in terms of number of Eastern Shore residents commuters.
outsideworkers75 <- outsideworkers[which(outsideworkers$commutersfromRegion >= quantile(na.omit(outsideworkers$commutersfromRegion), probs = 0.75)),]
ggplot(outsideworkers75, aes(x = NAME, y = commutersfromRegion))+
geom_bar(stat = 'identity', width = 0.5) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(x = "County", y = "Eastern Shore resident commuters")
These are the percentile calculations for Virginia counties based on the number of Eastern Shore residents who are employed in that county. These calculations do not include the number of Eastern Shore residents who are employed within the Eastern Shore. For example, the number of people who live in Albemarle County and commute to Charlottesville City are not reflected in this calculations. The bar graphs show the most common and least common work-destination counties for Eastern Shore residents who work outside of the Eastern Shore.
quantile(na.omit(outsideresidents$commuterstoRegion), probs = seq(0, 1, by= 0.05))
## 0% 5% 10% 15% 20% 25% 30% 35% 40% 45% 50%
## 1.00 1.00 2.00 3.00 4.00 4.00 5.00 6.00 6.40 8.00 8.50
## 55% 60% 65% 70% 75% 80% 85% 90% 95% 100%
## 9.00 11.00 15.65 19.00 29.75 34.00 48.10 59.90 117.90 401.00
Bottom 25th percentile (the least common work-destinations for Eastern Shore residents)
# Counties that are in the bottom 25th percentile in terms of number of Eastern Shore workers.
outsideres25 <- outsideresidents[which(outsideresidents$commuterstoRegion <= quantile(na.omit(outsideresidents$commuterstoRegion), probs = 0.25)),]
ggplot(outsideres25, aes(x = NAME, y = commuterstoRegion))+
geom_bar(stat = 'identity', width = 0.5) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(x = "County", y = "Eastern Shore workers")
Top 75th percentile (the most common work-destinations for Eastern Shore residents who work outside the Eastern Shore)
# Counties that are in the top 75th percentile in terms of number of Eastern Shore workers.
outsideres75 <- outsideresidents[which(outsideresidents$commuterstoRegion >= quantile(na.omit(outsideresidents$commuterstoRegion), probs = 0.75)),]
ggplot(outsideres75, aes(x = NAME, y = commuterstoRegion))+
geom_bar(stat = 'identity', width = 0.5) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(x = "County", y = "Eastern Shore workers")
The map offers another way to visualize where Eastern Shore residents commute most often. The counts of Eastern Shore residents who commute to work within the Eastern Shore are excluded from the legend so as to limit the range and allow for easier discrimination between the surrounding counties, but the number of commuters to each of the localities in the Eastern Shore is available by clicking on the locality.
east_lodes_all2$res <- ifelse(east_lodes_all2$w_county %in% eastfips, NA, east_lodes_all2$commutersfromRegion)
pal <- colorNumeric("plasma", reverse = TRUE, na.color = "lightgray", domain = east_lodes_all2$res)
leaflet(east_lodes_all2) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = east_lodes_all2,
fillColor = ~pal(res),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("County: ", east_lodes_all2$NAME, "<br>",
"Number of commuters: ", east_lodes_all2$commutersfromRegion)) %>%
addLegend("bottomright", pal = pal, values = east_lodes_all2$res,
title = "Number of Eastern Shore <br> region resident <br> commuters", opacity = 0.7)